﻿using System;

namespace ForgeCraft
{
    public class CmdFreeze : Command
    {
        public override string name { get { return "freeze"; } }
        public override string shortcut { get { return ""; } }
        public override string type { get { return "op"; } }
        public override bool consoleUsable { get { return false; } }
        public override Permission defaultRank { get { return Permission.Operator; } }
        public CmdFreeze() { }

        public override void Use(Player p, string message)
        {
            Player target = Server.FindPlayerByNick(message);

            if (target != null)
            {
                p.Message(Color.Red + "No player found!");
                return;
            }

            if (target.nick != target.name)
            {
                p.Message(Color.Red + "Warning: Player named " + target.name + " is using a nickname \"" + target.nick + "\"");
            }

            if (target.isFrozen)
            {
                target.Message(Color.Red + "You have been " + Color.Aqua + "frozen " + Color.Red + "by " + p.info.group.color + p.name + "!");
            }
            else
            {
                target.Message(Color.Red + "You are no longer frozen!");
            }

            target.isFrozen = !target.isFrozen;

        }

        public override void Help(Player p)
        {
            p.Message(Color.Aqua + "/freeze " + Color.Help + "- Freezes a player.");
        }
    }
}